﻿using System;
using System.Threading.Tasks;
using AutoMapper;
using Solution.Application.Commands.Users.Add.Dto;
using Solution.Application.Commands.Users.Detail.Dto;
using Solution.Domain.Repositories;
using Solution.Entity.Domain.Models;

namespace Solution.Application.Services.Imples
{
    public class UserService : UserRepository, IUserService
    {
        private readonly IMapper _mapper;

        public UserService(IMapper mapper)
        {
            _mapper = mapper;
        }

        public async Task<bool> CreateUsersAsync(CreateUserInput createUserInput)
        {
            var users = _mapper.Map<User>(createUserInput);
            return await InsertAsync(users) > 0;
        }

        public async Task<UserModel> GetUserAsync(GetUserInput getUserInput)
        {
            var user = await GetAsync<User, ulong>(getUserInput.UserId);
            return _mapper.Map<UserModel>(user);
        }
    }
}